import { axiosGet, axiosPost, axiosPut, axiosDelete } from '/@/api/RequestBase';
import { SqlSugarPagedList } from '/@/api/BaseDto';
import { BaseKeywordPageInput } from '/@/api/BaseDto';
import { BasViewModel, BasViewModelAddInput, BasViewModelUpdateInput, BasViewModelQueryInput } from './dto';

const service = 'BasViewModel/'; // 要写后面的斜杠, 不要写前面的斜杠

export function BasViewModelApi() {
	return {
		page: (data?: BaseKeywordPageInput) => {
			return axiosPost(service + 'page', data) as Promise<SqlSugarPagedList<BasViewModel>>;
		},
		get: (id: number) => {
			return axiosGet(service + `get/${id}`) as Promise<BasViewModel>;
		},
		add: (data?: BasViewModelAddInput) => {
			return axiosPost(service + 'add', data) as Promise<number>;
		},
		update: (data?: BasViewModelUpdateInput) => {
			return axiosPut(service + 'update', data) as Promise<boolean>;
		},
		delete: (id: number) => {
			return axiosDelete(service + `delete/${id}`) as Promise<boolean>;
		},
		queryFirst: (data?: BasViewModelQueryInput) => {
			return axiosPost(service + 'queryFirst', data) as Promise<BasViewModel>;
		},
		all: (data?: BasViewModelQueryInput) => {
			return axiosPost(service + 'all', data) as Promise<Array<BasViewModel>>;
		},
	};
}
